package com.lu.pojo.loop;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @Author:luzhenfang
 * @Date: 2020 3 20
 * @Desc: java 小练习
 * @Class：
 *      Exam.java
 *      PrintGraph.java
 */


public class Exam {
    public static void main(String[] args) throws Exception {
        // 自己的 图表绘制类
        PrintGraph graph = new PrintGraph();
        Scanner scanner = new Scanner(System.in);

        // 闭环
        while (true) {
            showMenu();
            System.out.print("请输入:");
            int choice = 0;
            try {
                choice = scanner.nextInt();
            } catch (Exception e) {
                throw new Exception("非法的输入");
            }

            switch (choice) {
                case 1:
                    graph.printRect(5, 6);
                    break;
                case 2:
                    graph.printTriangle(5, false);
                    break;
                case 3:
                    graph.printIsosceles(4);
                    break;
                case 4:
                    graph.printParallelogram(8);

                    break;
                case 5:
                    graph.printDiamond(8);
                    break;
                case 6:
                    graph.printPrime(100);
                    break;
                default:
                    System.out.println("Bye~");
                    System.exit(0);
                    break;
            }
            System.out.println();
        }

    }


    public static void showMenu() {

        List<String> arr = new ArrayList<>();
        arr.add("打印矩形");
        arr.add("打印直角三角形");
        arr.add("打印等腰三角形");
        arr.add("打印平行四边形");
        arr.add("打印菱形");
        arr.add("打印1-100 之间所有的质数");

        System.out.println("*********************");
        for (int i = 0; i < arr.size(); i++) {
            System.out.println((i + 1) + ". " + arr.get(i));
        }
        System.out.println("*********************");

    }

}
